<ul class="breadcrumb">
    <li>
        <a href="/u/<%=user.mail%>">Home</a> <span class="divider">/</span>
    </li>
    <li>
        <a href="/u/<%=user.mail%>?page=home-own&active=nav-list-6">Project Owned</a> <span class="divider">/</span>
    </li>
    <li class="active"></li>
</ul>

<div class="row-fluid">
    <div class="span2">
        <%- partial('home-nav-list') %>
    </div>
    <div class="span10">
    <div id="ccd_content">
        <form class="form-horizontal">
            <fieldset>
                <legend>Create a new project</legend>
                <div class="row-fluid">
                    <div class="span6">
                            <div class="control-group">
                                <label class="control-label" for="mail">Project Name</label>
                                <div class="controls">
                                    <input type="text" class="input-xlarge" id="mail" name="mail">
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" >Creator</label>
                                <div class="controls" style="padding-top: 5px">
                                    <p><%=user.mail%></p>
                                </div>
                            </div>
                            <div class="control-group">
                                <label class="control-label" for="textarea">Description</label>
                                <div class="controls">
                                    <textarea class="input-xlarge" id="textarea" rows="3"></textarea>
                                </div>
                            </div>
                        </div>
                    <!--div class="span6">
                        <div class="control-group">
                            <label class="control-label" for="optionsVis">公开性</label>
                            <div class="controls">
                                <label class="checkbox">
                                    <input type="checkbox" id="optionsVis" value="option1">
                                    是否所有人员可以参加
                                </label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="optionsVal">有效性</label>
                            <div class="controls">
                                <label class="checkbox">
                                    <input type="checkbox" id="optionsVal" value="option2">
                                    是否仍可修改
                                </label>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label">邀请人员</label>
                            <div class="controls">
                                <input type="text" class="input-xlarge">
                            </div>
                        </div>
                    </div-->
                </div>
                <div class="form-actions padding=10x">
                    <button type="button" class="btn btn-primary btn-save">Create</button>
                    <button type="reset" class="btn ">Clean</button>
                    <button type="button" class="btn btn-return">Return</button>
                </div>
            </fieldset>
        </form>
    </div>
    </div>
</div>

<script type="text/javascript">
    $(function(){
        $(".btn-save").live("click",function(){
            var that = $(this).parent().parent().children(".row-fluid").children(".span6");
            var cd_name = $(that).children().eq(0).find("input").val();
            var user = $(that).children().eq(1).find("p").text();
            var cd_description = $(that).children().eq(2).find("textarea").val();

            $.ajax({
                url: '/<%=user.mail%>/own/create',
                type: 'post',
                data: {
                    user: user,
                    cd_name :cd_name,
                    cd_description : cd_description
                },
                dataType: 'json',
                async: true,
                success: function(doc){
                    if(doc.docs.length === 1)  alert("Project successfully created");
                    else alert("Fail! There may be a same-name project or other problems")
                    return self.location="/u/<%=user.mail%>";;
                }
            });
        });

        $(".btn-return").live("click",function(){
            self.location="/u/<%=user.mail%>";
        });

        $(".nav-list li").live("click",function(){
            self.location="/u/<%=user.mail%>?active="+$(this).attr("class");
        })
    });
</script>